const Router = require('@koa/router');
const activitiesController = require('../controllers/activitiesController');

const router = new Router({ prefix: '/api/activities' });

// 获取所有可参与的旅游活动信息
/**
 * @swagger
 * /api/activities/list:
 *   get:
 *     summary: 获取所有可参与的旅游活动信息
 *     parameters:
 *       - in: query
 *         name: scenic_id
 *         schema:
 *           type: integer
 *         description: 景点 ID
 *       - in: query
 *         name: category
 *         schema:
 *           type: string
 *         description: 活动类别（如“体验活动”、“娱乐活动”）
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *         description: 页码（默认 1）
 *       - in: query
 *         name: limit
 *         schema:
 *           type: integer
 *         description: 每页条数（默认 10）
 *     responses:
 *       200:
 *         description: 成功获取活动信息
 *       500:
 *         description: 获取失败
 */
router.get('/list', activitiesController.getActivitiesList);

// 获取单个旅游活动的详细信息
/**
 * @swagger
 * /api/activities/{id}:
 *   get:
 *     summary: 获取单个旅游活动的详细信息
 *     parameters:
 *       - in: path
 *         name: id
 *         schema:
 *           type: integer
 *         required: true
 *         description: 活动 ID
 *     responses:
 *       200:
 *         description: 成功获取活动详情
 *       500:
 *         description: 获取失败
 */
router.get('/:id', activitiesController.getActivityById);

// 创建一个新的旅游活动
/**
 * @swagger
 * /api/activities/create:
 *   post:
 *     summary: 创建一个新的旅游活动
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               scenic_id:
 *                 type: integer
 *               activity_name:
 *                 type: string
 *               activity_type:
 *                 type: string
 *               price:
 *                 type: number
 *               description:
 *                 type: string
 *               start_time:
 *                 type: string
 *               end_time:
 *                 type: string
 *               location:
 *                 type: string
 *               max_participants:
 *                 type: integer
 *               image:
 *                 type: string
 *     responses:
 *       201:
 *         description: 活动创建成功
 *       500:
 *         description: 创建失败
 */
router.post('/create', activitiesController.createActivity);

// 用户报名参加某个活动
/**
 * @swagger
 * /api/activities/signup:
 *   post:
 *     summary: 用户报名参加某个活动
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               user_id:
 *                 type: integer
 *               activity_id:
 *                 type: integer
 *               participants:
 *                 type: integer
 *               contact_name:
 *                 type: string
 *               contact_phone:
 *                 type: string
 *     responses:
 *       201:
 *         description: 报名成功
 *       500:
 *         description: 报名失败
 */
router.post('/signup', activitiesController.signupForActivity);

// 查询用户报名的所有活动记录
/**
 * @swagger
 * /api/activities/signups/{user_id}:
 *   get:
 *     summary: 查询用户报名的所有活动记录
 *     parameters:
 *       - in: path
 *         name: user_id
 *         schema:
 *           type: integer
 *         required: true
 *         description: 用户 ID
 *     responses:
 *       200:
 *         description: 成功获取报名记录
 *       500:
 *         description: 获取失败
 */
router.get('/signups/:user_id', activitiesController.getUserSignups);

// 用户取消已报名的活动
/**
 * @swagger
 * /api/activities/cancel_signup:
 *   post:
 *     summary: 用户取消已报名的活动
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               signup_id:
 *                 type: integer
 *               user_id:
 *                 type: integer
 *     responses:
 *       200:
 *         description: 取消报名成功
 *       500:
 *         description: 取消报名失败
 */
router.post('/cancel_signup', activitiesController.cancelSignup);

// 管理员修改已发布的活动信息
/**
 * @swagger
 * /api/activities/update/{id}:
 *   put:
 *     summary: 管理员修改已发布的活动信息
 *     parameters:
 *       - in: path
 *         name: id
 *         schema:
 *           type: integer
 *         required: true
 *         description: 活动 ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               activity_name:
 *                 type: string
 *               activity_type:
 *                 type: string
 *               price:
 *                 type: number
 *               description:
 *                 type: string
 *               start_time:
 *                 type: string
 *               end_time:
 *                 type: string
 *               location:
 *                 type: string
 *               max_participants:
 *                 type: integer
 *               image:
 *                 type: string
 *     responses:
 *       200:
 *         description: 活动更新成功
 *       500:
 *         description: 更新失败
 */
router.put('/update/:id', activitiesController.updateActivity);

module.exports = router;